<pre>
<?php

function formatSecondsInterval( $inSeconds )
{
	$seconds = $inSeconds;
	$hours = floor( $seconds / 3600 );
	$seconds = $seconds - ( $hours * 3600 );
	$minutes = floor( $seconds / 60 );
	$seconds = $seconds - ( $minutes * 60 );
	
	$minutes = str_pad( $minutes, 2, "0", STR_PAD_LEFT );
	$seconds = str_pad( $seconds, 2, "0", STR_PAD_LEFT );
	
	$timeStr = $hours . ":" . $minutes . ":" . $seconds;
	echo $timeStr;
}

function func1()
{
	$t1 = microtime ();
	var_dump( $t1 );
	
	$t2 = microtime (true);
	var_dump( $t2 );
	
	$t3 = round( $t2 * 1000 );
	
	//$t3 = (string) $t3;
	//settype( $t3, "string" );
	$t3 = sprintf( "%f", $t3 );
	var_dump( $t3 );
	
	$userId = (string) 2000000;
	
	$execId = $userId . $t3;
	var_dump( $execId );
}


function func2()
{
	$time_start = microtime(true);

	// Sleep for a while
	usleep(1000000);

	$time_end = microtime(true);
	$time_span = $time_end - $time_start;
	
	echo "Did nothing in $time_span seconds\n";
}


function func3()
{
	$userId = 3436723;
	$userIdStr = sprintf( "%08d", $userId );
	echo "UserId string: " . $userIdStr;
	
	$timeStr = date( ymdGis );
	echo "\nTime string: " . $timeStr;
	
	list( $usec, $sec ) = explode( " ", microtime () );
	$usec = round( $usec * 1000000 );
	$usecStr = sprintf( "%06d", $usec );
	echo "\nMicroseconds string: " . $usecStr;
	
	$execId = $userIdStr . $timeStr . $usecStr;
	echo "\nExecId string: " . $execId;
}


function GenerateExecId( $userId )
{
	$userIdStr = sprintf( "%08d", $userId );
	
	$timeStr = date( ymdGis );
	
	list( $usec, $sec ) = explode( " ", microtime () );
	$usec = round( $usec * 1000000 );
	$usecStr = sprintf( "%06d", $usec );
	
	$execId = $userIdStr . $timeStr . $usecStr;
	
	return $execId;
}


function intervals()
{
	$january = new DateTime('2010-01-01 22:00');
	$february = new DateTime('2010-01-02 03:00');
	$interval = $february->diff($january);
	// %a will output the total number of days.
	echo $interval->format('%a total days')."\n";
	// While %d will only output the number of days not already covered by the
	// month.
	echo $interval->format('%m month, %d days')."\n";
	echo $interval->format( '%a日 %H:%I' )."\n";
}

// start execution
formatSecondsInterval( 7200 );

?>
</pre>
